/***********************************
 *           3/24/2014             *
 *       by Meow dev (arm genesis) *
 *                                 *
 ***********************************/
package com.meow.dev.engine;

import com.meow.dev.constante.EnrollmentConstance.PassWordType;

public class UserData {
	// (res,apnEnrollNumber,apnBackupNumber,apnMachinePrivilege,apnEnableFlag);
	private long enrollNumber;
	private long backupNumber;
	private long machinePrivilege;
	private long enableFlag;
	private UserDataEncode dataEncode;

	public static long ADMIN = 1;
	public static long USER = 0;
	public static long BACKUP_FINGER_P = 0;
	public static long BACKUP_PSW = 10;
	public static long BACKUP_CARD = 11;

	public long getEnrollNumber() {
		return enrollNumber;
	}

	public void setEnrollNumber(long enrollNumber) {
		this.enrollNumber = enrollNumber;
	}

	public long getBackupNumber() {
		return backupNumber;
	}

	public void setBackupNumber(long backupNumber) {
		this.backupNumber = backupNumber;
	}

	public long getMachinePrivilege() {
		return machinePrivilege;
	}

	public void setMachinePrivilege(long machinePrivilege) {
		this.machinePrivilege = machinePrivilege;
	}

	public long getEnableFlag() {
		return enableFlag;
	}

	public void setEnableFlag(long enableFlag) {
		this.enableFlag = enableFlag;
	}

	public String getRole() {
		if (machinePrivilege == 1) {
			return "ADMIN";
		}
		if (machinePrivilege == 0) {
			return "USER";
		}
		return "UNDEFINE";
	}

	public String getLoginType() {
		if (backupNumber == 0) {
			return "FINGER";
		}
		if (backupNumber == 10) {
			return "PASSWORD";
		}
		if (backupNumber == 11) {
			return "CARD";
		}

		return "UNDEFINE";
	}

	public UserDataEncode getDataEncode() {
		return dataEncode;
	}

	public void setDataEncode(UserDataEncode dataEncode) {
		this.dataEncode = dataEncode;
	}
	
	public PassWordType getPassWordType() {
		if (backupNumber == 0) {
			return PassWordType.FINGER;
		}
		if (backupNumber == 10) {
			return PassWordType.PASSWORD;
		}
		if (backupNumber == 11) {
			return PassWordType.CARD;
		}

		return null;
	}

	@Override
	public String toString() {
		return "enrollNumber=" + enrollNumber + ", backupNumber="
				+ backupNumber + ", machinePrivilege=" + machinePrivilege
				+ ", enableFlag=" + enableFlag + "," + dataEncode ;
	}

 

}
